package com.dustedpixels.jasmin.chips.z80.util;

/**
 * Z80 Disassembler.
 */
public final class Z80InstructionSet {
    private static final String[] baseInstructionNames = {
        /* 0x00 */ "NOP",
        /* 0x01 */ "LD BC,nn",
        /* 0x02 */ "LD (BC),A",
        /* 0x03 */ "INC BC",
        /* 0x04 */ "INC B",
        /* 0x05 */ "DEC B",
        /* 0x06 */ "LD B,n",
        /* 0x07 */ "RLCA",
        /* 0x08 */ "EX AF,AF'",
        /* 0x09 */ "ADD HL,BC",
        /* 0x0A */ "LD A,(BC)",
        /* 0x0B */ "DEC BC",
        /* 0x0C */ "INC C",
        /* 0x0D */ "DEC C",
        /* 0x0E */ "LC C,n",
        /* 0x0F */ "RRCA",
        /* 0x10 */ "DJNZ (PC+e)",
        /* 0x11 */ "LD DE,nn",
        /* 0x12 */ "LD (DE),A",
        /* 0x13 */ "INC DE",
        /* 0x14 */ "INC D",
        /* 0x15 */ "DEC D",
        /* 0x16 */ "LD D,n",
        /* 0x17 */ "RLA",
        /* 0x18 */ "JR (PC+e)",
        /* 0x19 */ "ADD HL,DE",
        /* 0x1A */ "LD A,(DE)",
        /* 0x1B */ "DEC DE",
        /* 0x1C */ "INC E",
        /* 0x1D */ "DEC E",
        /* 0x1E */ "LD E,n",
        /* 0x1F */ "RRA",
        /* 0x20 */ "JR NZ,(PC+e)",
        /* 0x21 */ "LD HL,nn",
        /* 0x22 */ "LD (nn),HL",
        /* 0x23 */ "INC HL",
        /* 0x24 */ "INC H",
        /* 0x25 */ "DEC H",
        /* 0x26 */ "LD H,n",
        /* 0x27 */ "DAA",
        /* 0x28 */ "JR Z,(PC+e)",
        /* 0x29 */ "ADD HL,HL",
        /* 0x2A */ "LD HL,(nn)",
        /* 0x2B */ "DEC HL",
        /* 0x2C */ "INC L",
        /* 0x2D */ "DEC L",
        /* 0x2E */ "LD L,n",
        /* 0x2F */ "CPL",
        /* 0x30 */ "JR NC,(PC+e)",
        /* 0x31 */ "LD SP,nn",
        /* 0x32 */ "LD (nn),A",
        /* 0x33 */ "INC SP",
        /* 0x34 */ "INC (HL)",
        /* 0x35 */ "DEC (HL)",
        /* 0x36 */ "LD (HL),n",
        /* 0x37 */ "SCF",
        /* 0x38 */ "JR C,(PC+e)",
        /* 0x39 */ "ADD HL,SP",
        /* 0x3A */ "LD A,(nn)",
        /* 0x3B */ "DEC SP",
        /* 0x3C */ "INC A",
        /* 0x3D */ "DEC A",
        /* 0x3E */ "LD A,n",
        /* 0x3F */ "CCF",
        /* 0x40 */ "LD B,B",
        /* 0x41 */ "LD B,C",
        /* 0x42 */ "LD B,D",
        /* 0x43 */ "LD B,E",
        /* 0x44 */ "LD B,H",
        /* 0x45 */ "LD B,L",
        /* 0x46 */ "LD B,(HL)",
        /* 0x47 */ "LD B,A",
        /* 0x48 */ "LD C,B",
        /* 0x49 */ "LD C,C",
        /* 0x4A */ "LD C,D",
        /* 0x4B */ "LD C,E",
        /* 0x4C */ "LD C,H",
        /* 0x4D */ "LD C,L",
        /* 0x4E */ "LD C,(HL)",
        /* 0x4F */ "LD C,A",
        /* 0x50 */ "LD D,B",
        /* 0x51 */ "LD D,C",
        /* 0x52 */ "LD D,D",
        /* 0x53 */ "LD D,E",
        /* 0x54 */ "LD D,H",
        /* 0x55 */ "LD D,L",
        /* 0x56 */ "LD D,(HL)",
        /* 0x57 */ "LD D,A",
        /* 0x58 */ "LD E,B",
        /* 0x59 */ "LD E,C",
        /* 0x5A */ "LD E,D",
        /* 0x5B */ "LD E,E",
        /* 0x5C */ "LD E,H",
        /* 0x5D */ "LD E,L",
        /* 0x5E */ "LD E,(HL)",
        /* 0x5F */ "LD E,A",
        /* 0x60 */ "LD H,B",
        /* 0x61 */ "LD H,C",
        /* 0x62 */ "LD H,D",
        /* 0x63 */ "LD H,E",
        /* 0x64 */ "LD H,H",
        /* 0x65 */ "LD H,L",
        /* 0x66 */ "LD H,(HL)",
        /* 0x67 */ "LD H,A",
        /* 0x68 */ "LD L,B",
        /* 0x69 */ "LD L,C",
        /* 0x6A */ "LD L,D",
        /* 0x6B */ "LD L,E",
        /* 0x6C */ "LD L,H",
        /* 0x6D */ "LD L,L",
        /* 0x6E */ "LD L,(HL)",
        /* 0x6F */ "LD L,A",
        /* 0x70 */ "LD (HL),B",
        /* 0x71 */ "LD (HL),C",
        /* 0x72 */ "LD (HL),D",
        /* 0x73 */ "LD (HL),E",
        /* 0x74 */ "LD (HL),H",
        /* 0x75 */ "LD (HL),L",
        /* 0x76 */ "HALT",
        /* 0x77 */ "LD (HL),A",
        /* 0x78 */ "LD A,B",
        /* 0x79 */ "LD A,C",
        /* 0x7A */ "LD A,D",
        /* 0x7B */ "LD A,E",
        /* 0x7C */ "LD A,H",
        /* 0x7D */ "LD A,L",
        /* 0x7E */ "LD A,(HL)",
        /* 0x7F */ "LD A,A",
        /* 0x80 */ "ADD A,B",
        /* 0x81 */ "ADD A,C",
        /* 0x82 */ "ADD A,D",
        /* 0x83 */ "ADD A,E",
        /* 0x84 */ "ADD A,H",
        /* 0x85 */ "ADD A,L",
        /* 0x86 */ "ADD A,(HL)",
        /* 0x87 */ "ADD A,A",
        /* 0x88 */ "ADC A,B",
        /* 0x89 */ "ADC A,C",
        /* 0x8A */ "ADC A,D",
        /* 0x8B */ "ADC A,E",
        /* 0x8C */ "ADC A,H",
        /* 0x8D */ "ADC A,L",
        /* 0x8E */ "ADC A,(HL)",
        /* 0x8F */ "ADC A,A",
        /* 0x90 */ "SUB B",
        /* 0x91 */ "SUB C",
        /* 0x92 */ "SUB D",
        /* 0x93 */ "SUB E",
        /* 0x94 */ "SUB H",
        /* 0x95 */ "SUB L",
        /* 0x96 */ "SUB (HL)",
        /* 0x97 */ "SUB A",
        /* 0x98 */ "SBC A,B",
        /* 0x99 */ "SBC A,C",
        /* 0x9A */ "SBC A,D",
        /* 0x9B */ "SBC A,E",
        /* 0x9C */ "SBC A,H",
        /* 0x9D */ "SBC A,L",
        /* 0x9E */ "SBC A,(HL)",
        /* 0x9F */ "SBC A,A",
        /* 0xA0 */ "AND B",
        /* 0xA1 */ "AND C",
        /* 0xA2 */ "AND D",
        /* 0xA3 */ "AND E",
        /* 0xA4 */ "AND H",
        /* 0xA5 */ "AND L",
        /* 0xA6 */ "AND (HL)",
        /* 0xA7 */ "AND A",
        /* 0xA8 */ "XOR B",
        /* 0xA9 */ "XOR C",
        /* 0xAA */ "XOR D",
        /* 0xAB */ "XOR E",
        /* 0xAC */ "XOR H",
        /* 0xAD */ "XOR L",
        /* 0xAE */ "XOR (HL)",
        /* 0xAF */ "XOR A",
        /* 0xB0 */ "OR B",
        /* 0xB1 */ "OR C",
        /* 0xB2 */ "OR D",
        /* 0xB3 */ "OR E",
        /* 0xB4 */ "OR H",
        /* 0xB5 */ "OR L",
        /* 0xB6 */ "OR (HL)",
        /* 0xB7 */ "OR A",
        /* 0xB8 */ "CP B",
        /* 0xB9 */ "CP C",
        /* 0xBA */ "CP D",
        /* 0xBB */ "CP E",
        /* 0xBC */ "CP H",
        /* 0xBD */ "CP L",
        /* 0xBE */ "CP (HL)",
        /* 0xBF */ "CP A",
        /* 0xC0 */ "RET NZ",
        /* 0xC1 */ "POP BC",
        /* 0xC2 */ "JP NZ,(nn)",
        /* 0xC3 */ "JP (nn)",
        /* 0xC4 */ "CALL NZ,(nn)",
        /* 0xC5 */ "PUSH BC",
        /* 0xC6 */ "ADD A,n",
        /* 0xC7 */ "RST 00H",
        /* 0xC8 */ "RET Z",
        /* 0xC9 */ "RET",
        /* 0xCA */ "JP Z,(nn)",
        /* 0xCB */ null,
        /* 0xCC */ "CALL Z,(nn)",
        /* 0xCD */ "CALL (nn)",
        /* 0xCE */ "ADC A,n",
        /* 0xCF */ "RST 08H",
        /* 0xD0 */ "RET NC",
        /* 0xD1 */ "POP DE",
        /* 0xD2 */ "JP NC,(nn)",
        /* 0xD3 */ "OUT (n),A",
        /* 0xD4 */ "CALL NC,(nn)",
        /* 0xD5 */ "PUSH DE",
        /* 0xD6 */ "SUB A,n",
        /* 0xD7 */ "RST 10H",
        /* 0xD8 */ "RET C",
        /* 0xD9 */ "EXX",
        /* 0xDA */ "JP C,(nn)",
        /* 0xDB */ "IN A,(n)",
        /* 0xDC */ "CALL C,(nn)",
        /* 0xDD */ null,
        /* 0xDE */ "SBC A,n",
        /* 0xDF */ "RST 18H",
        /* 0xE0 */ "RET PO",
        /* 0xE1 */ "POP HL",
        /* 0xE2 */ "JP PO,(nn)",
        /* 0xE3 */ "EX (SP),HL",
        /* 0xE4 */ "CALL PO,(nn)",
        /* 0xE5 */ "PUSH HL",
        /* 0xE6 */ "AND n",
        /* 0xE7 */ "RST 20H",
        /* 0xE8 */ "RET PE",
        /* 0xE9 */ "JP (HL)",
        /* 0xEA */ "JP PE,(nn)",
        /* 0xEB */ "EX DE,HL",
        /* 0xEC */ "CALL PE,(nn)",
        /* 0xED */ null,
        /* 0xEE */ "XOR n",
        /* 0xEF */ "RST 28H",
        /* 0xF0 */ "RET P",
        /* 0xF1 */ "POP AF",
        /* 0xF2 */ "JP P,(nn)",
        /* 0xF3 */ "DI",
        /* 0xF4 */ "CALL P,(nn)",
        /* 0xF5 */ "PUSH AF",
        /* 0xF6 */ "OR n",
        /* 0xF7 */ "RST 30H",
        /* 0xF8 */ "RET M",
        /* 0xF9 */ "LD SP,HL",
        /* 0xFA */ "JP M,(nn)",
        /* 0xFB */ "EI",
        /* 0xFC */ "CALL M,(nn)",
        /* 0xFD */ null,
        /* 0xFE */ "CP n",
        /* 0xFF */ "RST 38H"
    };
    
    private static final String[] cbInstructionNames = {
        /* 0x00 */ "RLC B",
        /* 0x01 */ "RLC C",
        /* 0x02 */ "RLC D",
        /* 0x03 */ "RLC E",
        /* 0x04 */ "RLC H",
        /* 0x05 */ "RLC L",
        /* 0x06 */ "RLC (HL)",
        /* 0x07 */ "RLC A",
        /* 0x08 */ "RRC B",
        /* 0x09 */ "RRC C",
        /* 0x0A */ "RRC D",
        /* 0x0B */ "RRC E",
        /* 0x0C */ "RRC H",
        /* 0x0D */ "RRC L",
        /* 0x0E */ "RRC (HL)",
        /* 0x0F */ "RRC A",
        /* 0x10 */ "RL B",
        /* 0x11 */ "RL C",
        /* 0x12 */ "RL D",
        /* 0x13 */ "RL E",
        /* 0x14 */ "RL H",
        /* 0x15 */ "RL L",
        /* 0x16 */ "RL (HL)",
        /* 0x17 */ "RL A",
        /* 0x18 */ "RR B",
        /* 0x19 */ "RR C",
        /* 0x1A */ "RR D",
        /* 0x1B */ "RR E",
        /* 0x1C */ "RR H",
        /* 0x1D */ "RR L",
        /* 0x1E */ "RR (HL)",
        /* 0x1F */ "RR A",
        /* 0x20 */ "SLA B",
        /* 0x21 */ "SLA C",
        /* 0x22 */ "SLA D",
        /* 0x23 */ "SLA E",
        /* 0x24 */ "SLA H",
        /* 0x25 */ "SLA L",
        /* 0x26 */ "SLA (HL)",
        /* 0x27 */ "SLA A",
        /* 0x28 */ "SRA B",
        /* 0x29 */ "SRA C",
        /* 0x2A */ "SRA D",
        /* 0x2B */ "SRA E",
        /* 0x2C */ "SRA H",
        /* 0x2D */ "SRA L",
        /* 0x2E */ "SRA (HL)",
        /* 0x2F */ "SRA A",
        /* 0x30 */ "SLL B",
        /* 0x31 */ "SLL C",
        /* 0x32 */ "SLL D",
        /* 0x33 */ "SLL E",
        /* 0x34 */ "SLL H",
        /* 0x35 */ "SLL L",
        /* 0x36 */ "SLL (HL)",
        /* 0x37 */ "SLL A",
        /* 0x38 */ "SRL B",
        /* 0x39 */ "SRL C",
        /* 0x3A */ "SRL D",
        /* 0x3B */ "SRL E",
        /* 0x3C */ "SRL H",
        /* 0x3D */ "SRL L",
        /* 0x3E */ "SRL (HL)",
        /* 0x3F */ "SRL A",
        /* 0x40 */ "BIT 0,B",
        /* 0x41 */ "BIT 0,C",
        /* 0x42 */ "BIT 0,D",
        /* 0x43 */ "BIT 0,E",
        /* 0x44 */ "BIT 0,H",
        /* 0x45 */ "BIT 0,L",
        /* 0x46 */ "BIT 0,(HL)",
        /* 0x47 */ "BIT 0,A",
        /* 0x48 */ "BIT 1,B",
        /* 0x49 */ "BIT 1,C",
        /* 0x4A */ "BIT 1,D",
        /* 0x4B */ "BIT 1,E",
        /* 0x4C */ "BIT 1,H",
        /* 0x4D */ "BIT 1,L",
        /* 0x4E */ "BIT 1,(HL)",
        /* 0x4F */ "BIT 1,A",
        /* 0x50 */ "BIT 2,B",
        /* 0x51 */ "BIT 2,C",
        /* 0x52 */ "BIT 2,D",
        /* 0x53 */ "BIT 2,E",
        /* 0x54 */ "BIT 2,H",
        /* 0x55 */ "BIT 2,L",
        /* 0x56 */ "BIT 2,(HL)",
        /* 0x57 */ "BIT 2,A",
        /* 0x58 */ "BIT 3,B",
        /* 0x59 */ "BIT 3,C",
        /* 0x5A */ "BIT 3,D",
        /* 0x5B */ "BIT 3,E",
        /* 0x5C */ "BIT 3,H",
        /* 0x5D */ "BIT 3,L",
        /* 0x5E */ "BIT 3,(HL)",
        /* 0x5F */ "BIT 3,A",
        /* 0x60 */ "BIT 4,B",
        /* 0x61 */ "BIT 4,C",
        /* 0x62 */ "BIT 4,D",
        /* 0x63 */ "BIT 4,E",
        /* 0x64 */ "BIT 4,H",
        /* 0x65 */ "BIT 4,L",
        /* 0x66 */ "BIT 4,(HL)",
        /* 0x67 */ "BIT 4,A",
        /* 0x68 */ "BIT 5,B",
        /* 0x69 */ "BIT 5,C",
        /* 0x6A */ "BIT 5,D",
        /* 0x6B */ "BIT 5,E",
        /* 0x6C */ "BIT 5,H",
        /* 0x6D */ "BIT 5,L",
        /* 0x6E */ "BIT 5,(HL)",
        /* 0x6F */ "BIT 5,A",
        /* 0x70 */ "BIT 6,B",
        /* 0x71 */ "BIT 6,C",
        /* 0x72 */ "BIT 6,D",
        /* 0x73 */ "BIT 6,E",
        /* 0x74 */ "BIT 6,H",
        /* 0x75 */ "BIT 6,L",
        /* 0x76 */ "BIT 6,(HL)",
        /* 0x77 */ "BIT 6,A",
        /* 0x78 */ "BIT 7,B",
        /* 0x79 */ "BIT 7,C",
        /* 0x7A */ "BIT 7,D",
        /* 0x7B */ "BIT 7,E",
        /* 0x7C */ "BIT 7,H",
        /* 0x7D */ "BIT 7,L",
        /* 0x7E */ "BIT 7,(HL)",
        /* 0x7F */ "BIT 7,A",
        /* 0x80 */ "RES 0,B",
        /* 0x81 */ "RES 0,C",
        /* 0x82 */ "RES 0,D",
        /* 0x83 */ "RES 0,E",
        /* 0x84 */ "RES 0,H",
        /* 0x85 */ "RES 0,L",
        /* 0x86 */ "RES 0,(HL)",
        /* 0x87 */ "RES 0,A",
        /* 0x88 */ "RES 1,B",
        /* 0x89 */ "RES 1,C",
        /* 0x8A */ "RES 1,D",
        /* 0x8B */ "RES 1,E",
        /* 0x8C */ "RES 1,H",
        /* 0x8D */ "RES 1,L",
        /* 0x8E */ "RES 1,(HL)",
        /* 0x8F */ "RES 1,A",
        /* 0x90 */ "RES 2,B",
        /* 0x91 */ "RES 2,C",
        /* 0x92 */ "RES 2,D",
        /* 0x93 */ "RES 2,E",
        /* 0x94 */ "RES 2,H",
        /* 0x95 */ "RES 2,L",
        /* 0x96 */ "RES 2,(HL)",
        /* 0x97 */ "RES 2,A",
        /* 0x98 */ "RES 3,B",
        /* 0x99 */ "RES 3,C",
        /* 0x9A */ "RES 3,D",
        /* 0x9B */ "RES 3,E",
        /* 0x9C */ "RES 3,H",
        /* 0x9D */ "RES 3,L",
        /* 0x9E */ "RES 3,(HL)",
        /* 0x9F */ "RES 3,A",
        /* 0xA0 */ "RES 4,B",
        /* 0xA1 */ "RES 4,C",
        /* 0xA2 */ "RES 4,D",
        /* 0xA3 */ "RES 4,E",
        /* 0xA4 */ "RES 4,H",
        /* 0xA5 */ "RES 4,L",
        /* 0xA6 */ "RES 4,(HL)",
        /* 0xA7 */ "RES 4,A",
        /* 0xA8 */ "RES 5,B",
        /* 0xA9 */ "RES 5,C",
        /* 0xAA */ "RES 5,D",
        /* 0xAB */ "RES 5,E",
        /* 0xAC */ "RES 5,H",
        /* 0xAD */ "RES 5,L",
        /* 0xAE */ "RES 5,(HL)",
        /* 0xAF */ "RES 5,A",
        /* 0xB0 */ "RES 6,B",
        /* 0xB1 */ "RES 6,C",
        /* 0xB2 */ "RES 6,D",
        /* 0xB3 */ "RES 6,E",
        /* 0xB4 */ "RES 6,H",
        /* 0xB5 */ "RES 6,L",
        /* 0xB6 */ "RES 6,(HL)",
        /* 0xB7 */ "RES 6,A",
        /* 0xB8 */ "RES 7,B",
        /* 0xB9 */ "RES 7,C",
        /* 0xBA */ "RES 7,D",
        /* 0xBB */ "RES 7,E",
        /* 0xBC */ "RES 7,H",
        /* 0xBD */ "RES 7,L",
        /* 0xBE */ "RES 7,(HL)",
        /* 0xBF */ "RES 7,A",
        /* 0xC0 */ "SET 0,B",
        /* 0xC1 */ "SET 0,C",
        /* 0xC2 */ "SET 0,D",
        /* 0xC3 */ "SET 0,E",
        /* 0xC4 */ "SET 0,H",
        /* 0xC5 */ "SET 0,L",
        /* 0xC6 */ "SET 0,(HL)",
        /* 0xC7 */ "SET 0,A",
        /* 0xC8 */ "SET 1,B",
        /* 0xC9 */ "SET 1,C",
        /* 0xCA */ "SET 1,D",
        /* 0xCB */ "SET 1,E",
        /* 0xCC */ "SET 1,H",
        /* 0xCD */ "SET 1,L",
        /* 0xCE */ "SET 1,(HL)",
        /* 0xCF */ "SET 1,A",
        /* 0xD0 */ "SET 2,B",
        /* 0xD1 */ "SET 2,C",
        /* 0xD2 */ "SET 2,D",
        /* 0xD3 */ "SET 2,E",
        /* 0xD4 */ "SET 2,H",
        /* 0xD5 */ "SET 2,L",
        /* 0xD6 */ "SET 2,(HL)",
        /* 0xD7 */ "SET 2,A",
        /* 0xD8 */ "SET 3,B",
        /* 0xD9 */ "SET 3,C",
        /* 0xDA */ "SET 3,D",
        /* 0xDB */ "SET 3,E",
        /* 0xDC */ "SET 3,H",
        /* 0xDD */ "SET 3,L",
        /* 0xDE */ "SET 3,(HL)",
        /* 0xDF */ "SET 3,A",
        /* 0xE0 */ "SET 4,B",
        /* 0xE1 */ "SET 4,C",
        /* 0xE2 */ "SET 4,D",
        /* 0xE3 */ "SET 4,E",
        /* 0xE4 */ "SET 4,H",
        /* 0xE5 */ "SET 4,L",
        /* 0xE6 */ "SET 4,(HL)",
        /* 0xE7 */ "SET 4,A",
        /* 0xE8 */ "SET 5,B",
        /* 0xE9 */ "SET 5,C",
        /* 0xEA */ "SET 5,D",
        /* 0xEB */ "SET 5,E",
        /* 0xEC */ "SET 5,H",
        /* 0xED */ "SET 5,L",
        /* 0xEE */ "SET 5,(HL)",
        /* 0xEF */ "SET 5,A",
        /* 0xF0 */ "SET 6,B",
        /* 0xF1 */ "SET 6,C",
        /* 0xF2 */ "SET 6,D",
        /* 0xF3 */ "SET 6,E",
        /* 0xF4 */ "SET 6,H",
        /* 0xF5 */ "SET 6,L",
        /* 0xF6 */ "SET 6,(HL)",
        /* 0xF7 */ "SET 6,A",
        /* 0xF8 */ "SET 7,B",
        /* 0xF9 */ "SET 7,C",
        /* 0xFA */ "SET 7,D",
        /* 0xFB */ "SET 7,E",
        /* 0xFC */ "SET 7,H",
        /* 0xFD */ "SET 7,L",
        /* 0xFE */ "SET 7,(HL)",
        /* 0xFF */ "SET 7,A"
    };
    
    private static final String[] ddInstructionNames = {
        /* 0x00 */ "NOP",
        /* 0x01 */ "NOP",
        /* 0x02 */ "NOP",
        /* 0x03 */ "NOP",
        /* 0x04 */ "NOP",
        /* 0x05 */ "NOP",
        /* 0x06 */ "NOP",
        /* 0x07 */ "NOP",
        /* 0x08 */ "NOP",
        /* 0x09 */ "ADD IX,BC",
        /* 0x0A */ "NOP",
        /* 0x0B */ "NOP",
        /* 0x0C */ "NOP",
        /* 0x0D */ "NOP",
        /* 0x0E */ "NOP",
        /* 0x0F */ "NOP",
        /* 0x10 */ "NOP",
        /* 0x11 */ "NOP",
        /* 0x12 */ "NOP",
        /* 0x13 */ "NOP",
        /* 0x14 */ "NOP",
        /* 0x15 */ "NOP",
        /* 0x16 */ "NOP",
        /* 0x17 */ "NOP",
        /* 0x18 */ "NOP",
        /* 0x19 */ "ADD IX,DE",
        /* 0x1A */ "NOP",
        /* 0x1B */ "NOP",
        /* 0x1C */ "NOP",
        /* 0x1D */ "NOP",
        /* 0x1E */ "NOP",
        /* 0x1F */ "NOP",
        /* 0x20 */ "NOP",
        /* 0x21 */ "LD IX,nn",
        /* 0x22 */ "LD (nn),IX",
        /* 0x23 */ "INC IX",
        /* 0x24 */ "INC IXh",
        /* 0x25 */ "DEC IXh",
        /* 0x26 */ "LD IXh,n",
        /* 0x27 */ "NOP",
        /* 0x28 */ "NOP",
        /* 0x29 */ "ADD IX,IX",
        /* 0x2A */ "LD IX,(nn)",
        /* 0x2B */ "DEC IX",
        /* 0x2C */ "INC IXl",
        /* 0x2D */ "DEC IXl",
        /* 0x2E */ "LD IXl,n",
        /* 0x2F */ "NOP",
        /* 0x30 */ "NOP",
        /* 0x31 */ "NOP",
        /* 0x32 */ "NOP",
        /* 0x33 */ "NOP",
        /* 0x34 */ "INC (IX+d)",
        /* 0x35 */ "DEC (IX+d)",
        /* 0x36 */ "LD (IX+d),n",
        /* 0x37 */ "NOP",
        /* 0x38 */ "NOP",
        /* 0x39 */ "ADD IX,SP",
        /* 0x3A */ "NOP",
        /* 0x3B */ "NOP",
        /* 0x3C */ "NOP",
        /* 0x3D */ "NOP",
        /* 0x3E */ "NOP",
        /* 0x3F */ "NOP",
        /* 0x40 */ "NOP",
        /* 0x41 */ "NOP",
        /* 0x42 */ "NOP",
        /* 0x43 */ "NOP",
        /* 0x44 */ "LD B,IXh",
        /* 0x45 */ "LD B,IXl",
        /* 0x46 */ "LD B,(IX+d)",
        /* 0x47 */ "NOP",
        /* 0x48 */ "NOP",
        /* 0x49 */ "NOP",
        /* 0x4A */ "NOP",
        /* 0x4B */ "NOP",
        /* 0x4C */ "LD C,IXh",
        /* 0x4D */ "LD C,IXl",
        /* 0x4E */ "LD C,(IX+d)",
        /* 0x4F */ "NOP",
        /* 0x50 */ "NOP",
        /* 0x51 */ "NOP",
        /* 0x52 */ "NOP",
        /* 0x53 */ "NOP",
        /* 0x54 */ "LD D,IXh",
        /* 0x55 */ "LD D,IXl",
        /* 0x56 */ "LD D,(IX+d)",
        /* 0x57 */ "NOP",
        /* 0x58 */ "NOP",
        /* 0x59 */ "NOP",
        /* 0x5A */ "NOP",
        /* 0x5B */ "NOP",
        /* 0x5C */ "LD E,IXh",
        /* 0x5D */ "LD E,IXl",
        /* 0x5E */ "LD E,(IX+d)",
        /* 0x5F */ "NOP",
        /* 0x60 */ "LD IXh,B",
        /* 0x61 */ "LD IXh,C",
        /* 0x62 */ "LD IXh,D",
        /* 0x63 */ "LD IXh,E",
        /* 0x64 */ "LD IXh,IXh",
        /* 0x65 */ "LD IXh,IXl",
        /* 0x66 */ "LD IXh,(IX+d)",
        /* 0x67 */ "LD IXh,A",
        /* 0x68 */ "LD IXl,B",
        /* 0x69 */ "LD IXl,C",
        /* 0x6A */ "LD IXl,D",
        /* 0x6B */ "LD IXl,E",
        /* 0x6C */ "LD IXl,IXh",
        /* 0x6D */ "LD IXl,IXl",
        /* 0x6E */ "LD IXl,(IX+d)",
        /* 0x6F */ "LD IXl,A",
        /* 0x70 */ "LD (IX+d),B",
        /* 0x71 */ "LD (IX+d),C",
        /* 0x72 */ "LD (IX+d),D",
        /* 0x73 */ "LD (IX+d),E",
        /* 0x74 */ "LD (IX+d),H",
        /* 0x75 */ "LD (IX+d),L",
        /* 0x76 */ "NOP",
        /* 0x77 */ "LD (IX+d),A",
        /* 0x78 */ "NOP",
        /* 0x79 */ "NOP",
        /* 0x7A */ "NOP",
        /* 0x7B */ "NOP",
        /* 0x7C */ "LD A,IXh",
        /* 0x7D */ "LD A,IXl",
        /* 0x7E */ "LD A,(IX+d)",
        /* 0x7F */ "NOP",
        /* 0x80 */ "NOP",
        /* 0x81 */ "NOP",
        /* 0x82 */ "NOP",
        /* 0x83 */ "NOP",
        /* 0x84 */ "ADD A,IXh",
        /* 0x85 */ "ADD A,IXl",
        /* 0x86 */ "ADD A,(IX+d)",
        /* 0x87 */ "NOP",
        /* 0x88 */ "NOP",
        /* 0x89 */ "NOP",
        /* 0x8A */ "NOP",
        /* 0x8B */ "NOP",
        /* 0x8C */ "ADC A,IXh",
        /* 0x8D */ "ADC A,IXl",
        /* 0x8E */ "ADC A,(IX+d)",
        /* 0x8F */ "NOP",
        /* 0x90 */ "NOP",
        /* 0x91 */ "NOP",
        /* 0x92 */ "NOP",
        /* 0x93 */ "NOP",
        /* 0x94 */ "SUB IXh",
        /* 0x95 */ "SUB IXl",
        /* 0x96 */ "SUB (IX+d)",
        /* 0x97 */ "NOP",
        /* 0x98 */ "NOP",
        /* 0x99 */ "NOP",
        /* 0x9A */ "NOP",
        /* 0x9B */ "NOP",
        /* 0x9C */ "SBC A,IXh",
        /* 0x9D */ "SBC A,IXl",
        /* 0x9E */ "SBC A,(IX+d)",
        /* 0x9F */ "NOP",
        /* 0xA0 */ "NOP",
        /* 0xA1 */ "NOP",
        /* 0xA2 */ "NOP",
        /* 0xA3 */ "NOP",
        /* 0xA4 */ "AND IXh",
        /* 0xA5 */ "AND IXl",
        /* 0xA6 */ "AND (IX+d)",
        /* 0xA7 */ "NOP",
        /* 0xA8 */ "NOP",
        /* 0xA9 */ "NOP",
        /* 0xAA */ "NOP",
        /* 0xAB */ "NOP",
        /* 0xAC */ "XOR IXh",
        /* 0xAD */ "XOR IXl",
        /* 0xAE */ "XOR (IX+d)",
        /* 0xAF */ "NOP",
        /* 0xB0 */ "NOP",
        /* 0xB1 */ "NOP",
        /* 0xB2 */ "NOP",
        /* 0xB3 */ "NOP",
        /* 0xB4 */ "OR IXh",
        /* 0xB5 */ "OR IXl",
        /* 0xB6 */ "OR (IX+d)",
        /* 0xB7 */ "NOP",
        /* 0xB8 */ "NOP",
        /* 0xB9 */ "NOP",
        /* 0xBA */ "NOP",
        /* 0xBB */ "NOP",
        /* 0xBC */ "CP IXh",
        /* 0xBD */ "CP IXl",
        /* 0xBE */ "CP (IX+d)",
        /* 0xBF */ "NOP",
        /* 0xC0 */ "NOP",    
        /* 0xC1 */ "NOP",    
        /* 0xC2 */ "NOP",    
        /* 0xC3 */ "NOP",    
        /* 0xC4 */ "NOP",    
        /* 0xC5 */ "NOP",    
        /* 0xC6 */ "NOP",    
        /* 0xC7 */ "NOP",    
        /* 0xC8 */ "NOP",    
        /* 0xC9 */ "NOP",    
        /* 0xCA */ "NOP",    
        /* 0xCB */ null,    
        /* 0xCC */ "NOP",    
        /* 0xCD */ "NOP",    
        /* 0xCE */ "NOP",    
        /* 0xCF */ "NOP",    
        /* 0xD0 */ "NOP",    
        /* 0xD1 */ "NOP",    
        /* 0xD2 */ "NOP",    
        /* 0xD3 */ "NOP",    
        /* 0xD4 */ "NOP",    
        /* 0xD5 */ "NOP",    
        /* 0xD6 */ "NOP",    
        /* 0xD7 */ "NOP",    
        /* 0xD8 */ "NOP",    
        /* 0xD9 */ "NOP",    
        /* 0xDA */ "NOP",    
        /* 0xDB */ "NOP",    
        /* 0xDC */ "NOP",    
        /* 0xDD */ null,    
        /* 0xDE */ "NOP",    
        /* 0xDF */ "NOP",    
        /* 0xE0 */ "NOP",
        /* 0xE1 */ "POP IX",
        /* 0xE2 */ "NOP",
        /* 0xE3 */ "EX (SP),IX",
        /* 0xE4 */ "NOP",
        /* 0xE5 */ "PUSH IX",
        /* 0xE6 */ "NOP",
        /* 0xE7 */ "NOP",
        /* 0xE8 */ "NOP",
        /* 0xE9 */ "JP (IX)",
        /* 0xEA */ "NOP",
        /* 0xEB */ "NOP",
        /* 0xEC */ "NOP",
        /* 0xED */ "NOP",
        /* 0xEE */ "NOP",
        /* 0xEF */ "NOP",
        /* 0xF0 */ "NOP",
        /* 0xF1 */ "NOP",
        /* 0xF2 */ "NOP",
        /* 0xF3 */ "NOP",
        /* 0xF4 */ "NOP",
        /* 0xF5 */ "NOP",
        /* 0xF6 */ "NOP",
        /* 0xF7 */ "NOP",
        /* 0xF8 */ "NOP",
        /* 0xF9 */ "LD SP,IX",
        /* 0xFA */ "NOP",
        /* 0xFB */ "NOP",
        /* 0xFC */ "NOP",
        /* 0xFD */ null,
        /* 0xFE */ "NOP",
        /* 0xFF */ "NOP",
    };

    private static final String[] edInstructionNames = {
        /* 0x00 */ "NOP",
        /* 0x01 */ "NOP",
        /* 0x02 */ "NOP",
        /* 0x03 */ "NOP",
        /* 0x04 */ "NOP",
        /* 0x05 */ "NOP",
        /* 0x06 */ "NOP",
        /* 0x07 */ "NOP",
        /* 0x08 */ "NOP",
        /* 0x09 */ "NOP",
        /* 0x0A */ "NOP",
        /* 0x0B */ "NOP",
        /* 0x0C */ "NOP",
        /* 0x0D */ "NOP",
        /* 0x0E */ "NOP",
        /* 0x0F */ "NOP",    
        /* 0x10 */ "NOP",
        /* 0x11 */ "NOP",
        /* 0x12 */ "NOP",
        /* 0x13 */ "NOP",
        /* 0x14 */ "NOP",
        /* 0x15 */ "NOP",
        /* 0x16 */ "NOP",
        /* 0x17 */ "NOP",
        /* 0x18 */ "NOP",
        /* 0x19 */ "NOP",
        /* 0x1A */ "NOP",
        /* 0x1B */ "NOP",
        /* 0x1C */ "NOP",
        /* 0x1D */ "NOP",
        /* 0x1E */ "NOP",
        /* 0x1F */ "NOP",    
        /* 0x20 */ "NOP",
        /* 0x21 */ "NOP",
        /* 0x22 */ "NOP",
        /* 0x23 */ "NOP",
        /* 0x24 */ "NOP",
        /* 0x25 */ "NOP",
        /* 0x26 */ "NOP",
        /* 0x27 */ "NOP",
        /* 0x28 */ "NOP",
        /* 0x29 */ "NOP",
        /* 0x2A */ "NOP",
        /* 0x2B */ "NOP",
        /* 0x2C */ "NOP",
        /* 0x2D */ "NOP",
        /* 0x2E */ "NOP",
        /* 0x2F */ "NOP",    
        /* 0x30 */ "NOP",
        /* 0x31 */ "NOP",
        /* 0x32 */ "NOP",
        /* 0x33 */ "NOP",
        /* 0x34 */ "NOP",
        /* 0x35 */ "NOP",
        /* 0x36 */ "NOP",
        /* 0x37 */ "NOP",
        /* 0x38 */ "NOP",
        /* 0x39 */ "NOP",
        /* 0x3A */ "NOP",
        /* 0x3B */ "NOP",
        /* 0x3C */ "NOP",
        /* 0x3D */ "NOP",
        /* 0x3E */ "NOP",
        /* 0x3F */ "NOP",
        /* 0x40 */ "IN B,(C)",        
        /* 0x41 */ "OUT (C),B",        
        /* 0x42 */ "SBC HL,BC",        
        /* 0x43 */ "LD (nn),BC",        
        /* 0x44 */ "NEG",        
        /* 0x45 */ "RETN",        
        /* 0x46 */ "IM 0",        
        /* 0x47 */ "LD I,A",        
        /* 0x48 */ "IN C,(C)",        
        /* 0x49 */ "OUT (C),C",        
        /* 0x4A */ "ADC HL,BC",        
        /* 0x4B */ "LD BC,(nn)",        
        /* 0x4C */ "NEG",        
        /* 0x4D */ "RETI",        
        /* 0x4E */ "IM 0",        
        /* 0x4F */ "LD R,A",        
        /* 0x50 */ "IN D,(C)",        
        /* 0x51 */ "OUT (C),D",        
        /* 0x52 */ "SBC HL,DE",        
        /* 0x53 */ "LD (nn),DE",        
        /* 0x54 */ "NEG",        
        /* 0x55 */ "RETN",        
        /* 0x56 */ "IM 1",        
        /* 0x57 */ "LD A,I",        
        /* 0x58 */ "IN E,(C)",        
        /* 0x59 */ "OUT (C),E",        
        /* 0x5A */ "ADC HL,DE",        
        /* 0x5B */ "LD DE,(nn)",        
        /* 0x5C */ "NEG",        
        /* 0x5D */ "RETN",        
        /* 0x5E */ "IM 2",        
        /* 0x5F */ "LD A,R",        
        /* 0x60 */ "IN H,(C)",        
        /* 0x61 */ "OUT (C),H",        
        /* 0x62 */ "SBC HL,HL",        
        /* 0x63 */ "LD (nn),HL",        
        /* 0x64 */ "NEG",        
        /* 0x65 */ "RETN",        
        /* 0x66 */ "IM 0",        
        /* 0x67 */ "RRD",        
        /* 0x68 */ "IN L,(C)",        
        /* 0x69 */ "OUT (C),L",        
        /* 0x6A */ "ADC HL,HL",        
        /* 0x6B */ "LD HL,(nn)",        
        /* 0x6C */ "NEG",        
        /* 0x6D */ "RETN",        
        /* 0x6E */ "IM 0",        
        /* 0x6F */ "RLD",        
        /* 0x70 */ "IN F,(C)",        
        /* 0x71 */ "OUT (C),0",        
        /* 0x72 */ "SBC HL,SP",        
        /* 0x73 */ "LD (nn),SP",        
        /* 0x74 */ "NEG",        
        /* 0x75 */ "RETN",        
        /* 0x76 */ "IM 1",        
        /* 0x77 */ "NOP",        
        /* 0x78 */ "IN A,(C)",        
        /* 0x79 */ "OUT (C),A",        
        /* 0x7A */ "ADC HL,SP",        
        /* 0x7B */ "LD SP,(nn)",        
        /* 0x7C */ "NEG",        
        /* 0x7D */ "RETN",        
        /* 0x7E */ "IM 2",        
        /* 0x7F */ "NOP",
        /* 0x80 */ "NOP",
        /* 0x81 */ "NOP",
        /* 0x82 */ "NOP",
        /* 0x83 */ "NOP",
        /* 0x84 */ "NOP",
        /* 0x85 */ "NOP",
        /* 0x86 */ "NOP",
        /* 0x87 */ "NOP",
        /* 0x88 */ "NOP",
        /* 0x89 */ "NOP",
        /* 0x8A */ "NOP",
        /* 0x8B */ "NOP",
        /* 0x8C */ "NOP",
        /* 0x8D */ "NOP",
        /* 0x8E */ "NOP",
        /* 0x8F */ "NOP",
        /* 0x90 */ "NOP",
        /* 0x91 */ "NOP",
        /* 0x92 */ "NOP",
        /* 0x93 */ "NOP",
        /* 0x94 */ "NOP",
        /* 0x95 */ "NOP",
        /* 0x96 */ "NOP",
        /* 0x97 */ "NOP",
        /* 0x98 */ "NOP",
        /* 0x99 */ "NOP",
        /* 0x9A */ "NOP",
        /* 0x9B */ "NOP",
        /* 0x9C */ "NOP",
        /* 0x9D */ "NOP",
        /* 0x9E */ "NOP",
        /* 0x9F */ "NOP",
        /* 0xA0 */ "LDI",
        /* 0xA1 */ "CPI",
        /* 0xA2 */ "INI",
        /* 0xA3 */ "OUTI",
        /* 0xA4 */ "NOP",
        /* 0xA5 */ "NOP",
        /* 0xA6 */ "NOP",
        /* 0xA7 */ "NOP",
        /* 0xA8 */ "LDD",
        /* 0xA9 */ "CPD",
        /* 0xAA */ "IND",
        /* 0xAB */ "OUTD",
        /* 0xAC */ "NOP",
        /* 0xAD */ "NOP",
        /* 0xAE */ "NOP",
        /* 0xAF */ "NOP",
        /* 0xB0 */ "LDIR",
        /* 0xB1 */ "CPIR",
        /* 0xB2 */ "INIR",
        /* 0xB3 */ "OTIR",
        /* 0xB4 */ "NOP",
        /* 0xB5 */ "NOP",
        /* 0xB6 */ "NOP",
        /* 0xB7 */ "NOP",
        /* 0xB8 */ "LDDR",
        /* 0xB9 */ "CPDR",
        /* 0xBA */ "INDR",
        /* 0xBB */ "OTDR",
        /* 0xBC */ "NOP",
        /* 0xBD */ "NOP",
        /* 0xBE */ "NOP",
        /* 0xBF */ "NOP",
        /* 0xC0 */ "NOP",
        /* 0xC1 */ "NOP",
        /* 0xC2 */ "NOP",
        /* 0xC3 */ "NOP",
        /* 0xC4 */ "NOP",
        /* 0xC5 */ "NOP",
        /* 0xC6 */ "NOP",
        /* 0xC7 */ "NOP",
        /* 0xC8 */ "NOP",
        /* 0xC9 */ "NOP",
        /* 0xCA */ "NOP",
        /* 0xCB */ "NOP",
        /* 0xCC */ "NOP",
        /* 0xCD */ "NOP",
        /* 0xCE */ "NOP",
        /* 0xCF */ "NOP",
        /* 0xD0 */ "NOP",
        /* 0xD1 */ "NOP",
        /* 0xD2 */ "NOP",
        /* 0xD3 */ "NOP",
        /* 0xD4 */ "NOP",
        /* 0xD5 */ "NOP",
        /* 0xD6 */ "NOP",
        /* 0xD7 */ "NOP",
        /* 0xD8 */ "NOP",
        /* 0xD9 */ "NOP",
        /* 0xDA */ "NOP",
        /* 0xDB */ "NOP",
        /* 0xDC */ "NOP",
        /* 0xDD */ "NOP",
        /* 0xDE */ "NOP",
        /* 0xDF */ "NOP",
        /* 0xE0 */ "NOP",
        /* 0xE1 */ "NOP",
        /* 0xE2 */ "NOP",
        /* 0xE3 */ "NOP",
        /* 0xE4 */ "NOP",
        /* 0xE5 */ "NOP",
        /* 0xE6 */ "NOP",
        /* 0xE7 */ "NOP",
        /* 0xE8 */ "NOP",
        /* 0xE9 */ "NOP",
        /* 0xEA */ "NOP",
        /* 0xEB */ "NOP",
        /* 0xEC */ "NOP",
        /* 0xED */ "NOP",
        /* 0xEE */ "NOP",
        /* 0xEF */ "NOP",
        /* 0xF0 */ "NOP",
        /* 0xF1 */ "NOP",
        /* 0xF2 */ "NOP",
        /* 0xF3 */ "NOP",
        /* 0xF4 */ "NOP",
        /* 0xF5 */ "NOP",
        /* 0xF6 */ "NOP",
        /* 0xF7 */ "NOP",
        /* 0xF8 */ "NOP",
        /* 0xF9 */ "NOP",
        /* 0xFA */ "NOP",
        /* 0xFB */ "NOP",
        /* 0xFC */ "NOP",
        /* 0xFD */ "NOP",
        /* 0xFE */ "NOP",
        /* 0xFF */ "NOP"
    };
    
    private static final String[] ddcbInstructionNames = {
        /* 0x00 */ "RLC (IX+d),B",
        /* 0x01 */ "RLC (IX+d),C",
        /* 0x02 */ "RLC (IX+d),D",
        /* 0x03 */ "RLC (IX+d),E",
        /* 0x04 */ "RLC (IX+d),H",
        /* 0x05 */ "RLC (IX+d),L",
        /* 0x06 */ "RLC (IX+d)",
        /* 0x07 */ "RLC (IX+d),A",
        /* 0x08 */ "RRC (IX+d),B",
        /* 0x09 */ "RRC (IX+d),C",
        /* 0x0A */ "RRC (IX+d),D",
        /* 0x0B */ "RRC (IX+d),E",
        /* 0x0C */ "RRC (IX+d),H",
        /* 0x0D */ "RRC (IX+d),L",
        /* 0x0E */ "RRC (IX+d)",
        /* 0x0F */ "RRC (IX+d),A",
        /* 0x10 */ "RL (IX+d),B",
        /* 0x11 */ "RL (IX+d),C",
        /* 0x12 */ "RL (IX+d),D",
        /* 0x13 */ "RL (IX+d),E",
        /* 0x14 */ "RL (IX+d),H",
        /* 0x15 */ "RL (IX+d),L",
        /* 0x16 */ "RL (IX+d)",
        /* 0x17 */ "RL (IX+d),A",
        /* 0x18 */ "RR (IX+d),B",
        /* 0x19 */ "RR (IX+d),C",
        /* 0x1A */ "RR (IX+d),D",
        /* 0x1B */ "RR (IX+d),E",
        /* 0x1C */ "RR (IX+d),H",
        /* 0x1D */ "RR (IX+d),L",
        /* 0x1E */ "RR (IX+d)",
        /* 0x1F */ "RR (IX+d),A",
        /* 0x20 */ "SLA (IX+d),B",
        /* 0x21 */ "SLA (IX+d),C",
        /* 0x22 */ "SLA (IX+d),D",
        /* 0x23 */ "SLA (IX+d),E",
        /* 0x24 */ "SLA (IX+d),H",
        /* 0x25 */ "SLA (IX+d),L",
        /* 0x26 */ "SLA (IX+d)",
        /* 0x27 */ "SLA (IX+d),A",
        /* 0x28 */ "SRA (IX+d),B",
        /* 0x29 */ "SRA (IX+d),C",
        /* 0x2A */ "SRA (IX+d),D",
        /* 0x2B */ "SRA (IX+d),E",
        /* 0x2C */ "SRA (IX+d),H",
        /* 0x2D */ "SRA (IX+d),L",
        /* 0x2E */ "SRA (IX+d)",
        /* 0x2F */ "SRA (IX+d),A",
        /* 0x30 */ "SLL (IX+d),B",
        /* 0x31 */ "SLL (IX+d),C",
        /* 0x32 */ "SLL (IX+d),D",
        /* 0x33 */ "SLL (IX+d),E",
        /* 0x34 */ "SLL (IX+d),H",
        /* 0x35 */ "SLL (IX+d),L",
        /* 0x36 */ "SLL (IX+d)",
        /* 0x37 */ "SLL (IX+d),A",
        /* 0x38 */ "SRL (IX+d),B",
        /* 0x39 */ "SRL (IX+d),C",
        /* 0x3A */ "SRL (IX+d),D",
        /* 0x3B */ "SRL (IX+d),E",
        /* 0x3C */ "SRL (IX+d),H",
        /* 0x3D */ "SRL (IX+d),L",
        /* 0x3E */ "SRL (IX+d)",
        /* 0x3F */ "SRL (IX+d),A",
        /* 0x40 */ "BIT 0,(IX+d)",
        /* 0x41 */ "BIT 0,(IX+d)",
        /* 0x42 */ "BIT 0,(IX+d)",
        /* 0x43 */ "BIT 0,(IX+d)",
        /* 0x44 */ "BIT 0,(IX+d)",
        /* 0x45 */ "BIT 0,(IX+d)",
        /* 0x46 */ "BIT 0,(IX+d)",
        /* 0x47 */ "BIT 0,(IX+d)",
        /* 0x48 */ "BIT 1,(IX+d)",
        /* 0x49 */ "BIT 1,(IX+d)",
        /* 0x4A */ "BIT 1,(IX+d)",
        /* 0x4B */ "BIT 1,(IX+d)",
        /* 0x4C */ "BIT 1,(IX+d)",
        /* 0x4D */ "BIT 1,(IX+d)",
        /* 0x4E */ "BIT 1,(IX+d)",
        /* 0x4F */ "BIT 1,(IX+d)",
        /* 0x50 */ "BIT 2,(IX+d)",
        /* 0x51 */ "BIT 2,(IX+d)",
        /* 0x52 */ "BIT 2,(IX+d)",
        /* 0x53 */ "BIT 2,(IX+d)",
        /* 0x54 */ "BIT 2,(IX+d)",
        /* 0x55 */ "BIT 2,(IX+d)",
        /* 0x56 */ "BIT 2,(IX+d)",
        /* 0x57 */ "BIT 2,(IX+d)",
        /* 0x58 */ "BIT 3,(IX+d)",
        /* 0x59 */ "BIT 3,(IX+d)",
        /* 0x5A */ "BIT 3,(IX+d)",
        /* 0x5B */ "BIT 3,(IX+d)",
        /* 0x5C */ "BIT 3,(IX+d)",
        /* 0x5D */ "BIT 3,(IX+d)",
        /* 0x5E */ "BIT 3,(IX+d)",
        /* 0x5F */ "BIT 3,(IX+d)",
        /* 0x60 */ "BIT 4,(IX+d)",
        /* 0x61 */ "BIT 4,(IX+d)",
        /* 0x62 */ "BIT 4,(IX+d)",
        /* 0x63 */ "BIT 4,(IX+d)",
        /* 0x64 */ "BIT 4,(IX+d)",
        /* 0x65 */ "BIT 4,(IX+d)",
        /* 0x66 */ "BIT 4,(IX+d)",
        /* 0x67 */ "BIT 4,(IX+d)",
        /* 0x68 */ "BIT 5,(IX+d)",
        /* 0x69 */ "BIT 5,(IX+d)",
        /* 0x6A */ "BIT 5,(IX+d)",
        /* 0x6B */ "BIT 5,(IX+d)",
        /* 0x6C */ "BIT 5,(IX+d)",
        /* 0x6D */ "BIT 5,(IX+d)",
        /* 0x6E */ "BIT 5,(IX+d)",
        /* 0x6F */ "BIT 5,(IX+d)",
        /* 0x70 */ "BIT 6,(IX+d)",
        /* 0x71 */ "BIT 6,(IX+d)",
        /* 0x72 */ "BIT 6,(IX+d)",
        /* 0x73 */ "BIT 6,(IX+d)",
        /* 0x74 */ "BIT 6,(IX+d)",
        /* 0x75 */ "BIT 6,(IX+d)",
        /* 0x76 */ "BIT 6,(IX+d)",
        /* 0x77 */ "BIT 6,(IX+d)",
        /* 0x78 */ "BIT 7,(IX+d)",
        /* 0x79 */ "BIT 7,(IX+d)",
        /* 0x7A */ "BIT 7,(IX+d)",
        /* 0x7B */ "BIT 7,(IX+d)",
        /* 0x7C */ "BIT 7,(IX+d)",
        /* 0x7D */ "BIT 7,(IX+d)",
        /* 0x7E */ "BIT 7,(IX+d)",
        /* 0x7F */ "BIT 7,(IX+d)",
        /* 0x80 */ "RES 0,(IX+d),B",
        /* 0x81 */ "RES 0,(IX+d),C",
        /* 0x82 */ "RES 0,(IX+d),D",
        /* 0x83 */ "RES 0,(IX+d),E",
        /* 0x84 */ "RES 0,(IX+d),H",
        /* 0x85 */ "RES 0,(IX+d),L",
        /* 0x86 */ "RES 0,(IX+d)",
        /* 0x87 */ "RES 0,(IX+d),A",
        /* 0x88 */ "RES 1,(IX+d),B",
        /* 0x89 */ "RES 1,(IX+d),C",
        /* 0x8A */ "RES 1,(IX+d),D",
        /* 0x8B */ "RES 1,(IX+d),E",
        /* 0x8C */ "RES 1,(IX+d),H",
        /* 0x8D */ "RES 1,(IX+d),L",
        /* 0x8E */ "RES 1,(IX+d)",
        /* 0x8F */ "RES 1,(IX+d),A",
        /* 0x90 */ "RES 2,(IX+d),B",
        /* 0x91 */ "RES 2,(IX+d),C",
        /* 0x92 */ "RES 2,(IX+d),D",
        /* 0x93 */ "RES 2,(IX+d),E",
        /* 0x94 */ "RES 2,(IX+d),H",
        /* 0x95 */ "RES 2,(IX+d),L",
        /* 0x96 */ "RES 2,(IX+d)",
        /* 0x97 */ "RES 2,(IX+d),A",
        /* 0x98 */ "RES 3,(IX+d),B",
        /* 0x99 */ "RES 3,(IX+d),C",
        /* 0x9A */ "RES 3,(IX+d),D",
        /* 0x9B */ "RES 3,(IX+d),E",
        /* 0x9C */ "RES 3,(IX+d),H",
        /* 0x9D */ "RES 3,(IX+d),L",
        /* 0x9E */ "RES 3,(IX+d)",
        /* 0x9F */ "RES 3,(IX+d),A",
        /* 0xA0 */ "RES 4,(IX+d),B",
        /* 0xA1 */ "RES 4,(IX+d),C",
        /* 0xA2 */ "RES 4,(IX+d),D",
        /* 0xA3 */ "RES 4,(IX+d),E",
        /* 0xA4 */ "RES 4,(IX+d),H",
        /* 0xA5 */ "RES 4,(IX+d),L",
        /* 0xA6 */ "RES 4,(IX+d)",
        /* 0xA7 */ "RES 4,(IX+d),A",
        /* 0xA8 */ "RES 5,(IX+d),B",
        /* 0xA9 */ "RES 5,(IX+d),C",
        /* 0xAA */ "RES 5,(IX+d),D",
        /* 0xAB */ "RES 5,(IX+d),E",
        /* 0xAC */ "RES 5,(IX+d),H",
        /* 0xAD */ "RES 5,(IX+d),L",
        /* 0xAE */ "RES 5,(IX+d)",
        /* 0xAF */ "RES 5,(IX+d),A",
        /* 0xB0 */ "RES 6,(IX+d),B",
        /* 0xB1 */ "RES 6,(IX+d),C",
        /* 0xB2 */ "RES 6,(IX+d),D",
        /* 0xB3 */ "RES 6,(IX+d),E",
        /* 0xB4 */ "RES 6,(IX+d),H",
        /* 0xB5 */ "RES 6,(IX+d),L",
        /* 0xB6 */ "RES 6,(IX+d)",
        /* 0xB7 */ "RES 6,(IX+d),A",
        /* 0xB8 */ "RES 7,(IX+d),B",
        /* 0xB9 */ "RES 7,(IX+d),C",
        /* 0xBA */ "RES 7,(IX+d),D",
        /* 0xBB */ "RES 7,(IX+d),E",
        /* 0xBC */ "RES 7,(IX+d),H",
        /* 0xBD */ "RES 7,(IX+d),L",
        /* 0xBE */ "RES 7,(IX+d)",
        /* 0xBF */ "RES 7,(IX+d),A",
        /* 0xC0 */ "SET 0,(IX+d),B",
        /* 0xC1 */ "SET 0,(IX+d),C",
        /* 0xC2 */ "SET 0,(IX+d),D",
        /* 0xC3 */ "SET 0,(IX+d),E",
        /* 0xC4 */ "SET 0,(IX+d),H",
        /* 0xC5 */ "SET 0,(IX+d),L",
        /* 0xC6 */ "SET 0,(IX+d)",
        /* 0xC7 */ "SET 0,(IX+d),A",
        /* 0xC8 */ "SET 1,(IX+d),B",
        /* 0xC9 */ "SET 1,(IX+d),C",
        /* 0xCA */ "SET 1,(IX+d),D",
        /* 0xCB */ "SET 1,(IX+d),E",
        /* 0xCC */ "SET 1,(IX+d),H",
        /* 0xCD */ "SET 1,(IX+d),L",
        /* 0xCE */ "SET 1,(IX+d)",
        /* 0xCF */ "SET 1,(IX+d),A",
        /* 0xD0 */ "SET 2,(IX+d),B",
        /* 0xD1 */ "SET 2,(IX+d),C",
        /* 0xD2 */ "SET 2,(IX+d),D",
        /* 0xD3 */ "SET 2,(IX+d),E",
        /* 0xD4 */ "SET 2,(IX+d),H",
        /* 0xD5 */ "SET 2,(IX+d),L",
        /* 0xD6 */ "SET 2,(IX+d)",
        /* 0xD7 */ "SET 2,(IX+d),A",
        /* 0xD8 */ "SET 3,(IX+d),B",
        /* 0xD9 */ "SET 3,(IX+d),C",
        /* 0xDA */ "SET 3,(IX+d),D",
        /* 0xDB */ "SET 3,(IX+d),E",
        /* 0xDC */ "SET 3,(IX+d),H",
        /* 0xDD */ "SET 3,(IX+d),L",
        /* 0xDE */ "SET 3,(IX+d)",
        /* 0xDF */ "SET 3,(IX+d),A",
        /* 0xE0 */ "SET 4,(IX+d),B",
        /* 0xE1 */ "SET 4,(IX+d),C",
        /* 0xE2 */ "SET 4,(IX+d),D",
        /* 0xE3 */ "SET 4,(IX+d),E",
        /* 0xE4 */ "SET 4,(IX+d),H",
        /* 0xE5 */ "SET 4,(IX+d),L",
        /* 0xE6 */ "SET 4,(IX+d)",
        /* 0xE7 */ "SET 4,(IX+d),A",
        /* 0xE8 */ "SET 5,(IX+d),B",
        /* 0xE9 */ "SET 5,(IX+d),C",
        /* 0xEA */ "SET 5,(IX+d),D",
        /* 0xEB */ "SET 5,(IX+d),E",
        /* 0xEC */ "SET 5,(IX+d),H",
        /* 0xED */ "SET 5,(IX+d),L",
        /* 0xEE */ "SET 5,(IX+d)",
        /* 0xEF */ "SET 5,(IX+d),A",
        /* 0xF0 */ "SET 6,(IX+d),B",
        /* 0xF1 */ "SET 6,(IX+d),C",
        /* 0xF2 */ "SET 6,(IX+d),D",
        /* 0xF3 */ "SET 6,(IX+d),E",
        /* 0xF4 */ "SET 6,(IX+d),H",
        /* 0xF5 */ "SET 6,(IX+d),L",
        /* 0xF6 */ "SET 6,(IX+d)",
        /* 0xF7 */ "SET 6,(IX+d),A",
        /* 0xF8 */ "SET 7,(IX+d),B",
        /* 0xF9 */ "SET 7,(IX+d),C",
        /* 0xFA */ "SET 7,(IX+d),D",
        /* 0xFB */ "SET 7,(IX+d),E",
        /* 0xFC */ "SET 7,(IX+d),H",
        /* 0xFD */ "SET 7,(IX+d),L",
        /* 0xFE */ "SET 7,(IX+d)",
        /* 0xFF */ "SET 7,(IX+d),A",
    };

    /**
     * Returns instruction name from base instruction set. The opcode must be in
     * range 0..255. Returns null for following prefix opcodes: 0xCB, 0xDD,
     * 0xED, 0xFD.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getBaseInstructionName(int opcode) {
        return baseInstructionNames[opcode];
    }

    /**
     * Returns instruction name from CB instruction set. The opcode must be in
     * range 0..255.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getCBInstructionName(int opcode) {
        return cbInstructionNames[opcode];
    }

    /**
     * Returns instruction name from DD instruction set. The opcode must be in
     * range 0..255. Returns null for following prefix opcodes: 0xCB, 0xDD,
     * 0xFD.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getDDInstructionName(int opcode) {
        return ddInstructionNames[opcode];
    }

    /**
     * Returns instruction name from ED instruction set. The opcode must be in
     * range 0..255.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getEDInstructionName(int opcode) {
        return edInstructionNames[opcode];
    }

    /**
     * Returns instruction name from FD instruction set. The opcode must be in
     * range 0..255. Returns null for following prefix opcodes: 0xCB, 0xDD,
     * 0xFD.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getFDInstructionName(int opcode) {
        return getDDInstructionName(opcode).replaceAll("IX", "IY");
    }

    /**
     * Returns instruction name from DDCB instruction set. The opcode must be in
     * range 0..255.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getDDCBInstructionName(int opcode) {
        return ddcbInstructionNames[opcode];
    }

    /**
     * Returns instruction name from FDCB instruction set. The opcode must be in
     * range 0..255.
     * 
     * @param opcode The opcode.
     * @return The instruction name.
     */
    public String getFDCBInstructionName(int opcode) {
        return getDDCBInstructionName(opcode).replaceAll("IX", "IY");
    }
    
    public String getBaseOpcodeAndInstructionName(int opcode) {
        String name = getBaseInstructionName(opcode);
        
        if (name.indexOf("nn") != -1) {
            name = hex(opcode) + " n n      " + name;
        } else if (name.indexOf("n") != -1) {
            name = hex(opcode) + " n        " + name;
        } else if (name.indexOf("d") != -1) {
            name = hex(opcode) + " d        " + name;
        } else if (name.indexOf("e") != -1) {
            name = hex(opcode) + " e        " + name;
        } else {
            name = hex(opcode) + "          " + name;
        }
        
        return name;
    }

    public String getCBOpcodeAndInstructionName(int opcode) {
        return "CB" + hex(opcode) + "        " + getCBInstructionName(opcode);
    }

    public String getDDOpcodeAndInstructionName(int opcode) {
        String name = getDDInstructionName(opcode);
        
        if (name.indexOf("nn") != -1) {
            name = "DD" + hex(opcode) + " n n    " + name;
        } else if (name.indexOf("n") != -1) {
            name = "DD" + hex(opcode) + " n      " + name;
        } else if (name.indexOf("d") != -1) {
            name = "DD" + hex(opcode) + " d      " + name;
        } else if (name.indexOf("e") != -1) {
            name = "DD" + hex(opcode) + " e      " + name;
        } else {
            name = "DD" + hex(opcode) + "        " + name;
        }
        
        return name;
    }
    
    public String getEDOpcodeAndInstructionName(int opcode) {
        String name = getEDInstructionName(opcode);
        
        if (name.indexOf("nn") != -1) {
            name = "ED" + hex(opcode) + " n n    " + name;
        } else if (name.indexOf("n") != -1) {
            name = "ED" + hex(opcode) + " n      " + name;
        } else if (name.indexOf("d") != -1) {
            name = "ED" + hex(opcode) + " d      " + name;
        } else if (name.indexOf("e") != -1) {
            name = "ED" + hex(opcode) + " e      " + name;
        } else {
            name = "ED" + hex(opcode) + "        " + name;
        }
        
        return name;
    }
    
    public String getFDOpcodeAndInstructionName(int opcode) {
        return getDDOpcodeAndInstructionName(opcode).
            replaceAll("DD", "FD").replaceAll("IX", "IY");
    }

    public String getDDCBOpcodeAndInstructionName(int opcode) {
        return "DDCB d " + hex(opcode) + "   " + getDDCBInstructionName(opcode);
    }

    public String getFDCBOpcodeAndInstructionName(int opcode) {
        return getDDCBOpcodeAndInstructionName(opcode).
            replaceAll("DD", "FD").replaceAll("IX", "IY");
    }

    /**
     * Prints a list of all Z80 instructions on standard output.
     */
    public void printInstructionSet() {
        for (int opcode = 0; opcode <= 0xFF; opcode++) {
            if (opcode == 0xCB) {
                for (int cbOpcode = 0; cbOpcode <= 0xFF; cbOpcode++) {
                    System.out.println(getCBOpcodeAndInstructionName(cbOpcode));
                }
                
            } else if (opcode == 0xDD) {
                for (int ddOpcode = 0; ddOpcode <= 0xFF; ddOpcode++) {
                    if (ddOpcode == 0xCB) {
                        for (int cbOpcode = 0; cbOpcode <= 0xFF; cbOpcode++) {
                            System.out.println(getDDCBOpcodeAndInstructionName(cbOpcode));
                        }
                    } else if (ddOpcode == 0xDD) {
                        
                    } else if (ddOpcode == 0xFD) {
                        
                    } else {
                        System.out.println(getDDOpcodeAndInstructionName(ddOpcode));
                    }
                }

            } else if (opcode == 0xED) {
                for (int edOpcode = 0; edOpcode <= 0xFF; edOpcode++) {
                    System.out.println(getEDOpcodeAndInstructionName(edOpcode));
                }

            } else if (opcode == 0xFD) {
                for (int fdOpcode = 0; fdOpcode <= 0xFF; fdOpcode++) {
                    if (fdOpcode == 0xCB) {
                        for (int cbOpcode = 0; cbOpcode <= 0xFF; cbOpcode++) {
                            System.out.println(getFDCBOpcodeAndInstructionName(cbOpcode));
                        }
                    } else if (fdOpcode == 0xDD) {
                        
                    } else if (fdOpcode == 0xFD) {
                        
                    } else {
                        System.out.println(getDDOpcodeAndInstructionName(fdOpcode));
                    }
                }

            } else {
                System.out.println(getBaseOpcodeAndInstructionName(opcode));
            }
        }
    }

    /**
     * Returns opcode in HEX notation.
     * 
     * @param opcode The opcode.
     * @return The opcode in HEX notation.
     */
    private String hex(int opcode) {
        return Integer.toHexString(0x100 | opcode).substring(1).toUpperCase();
    }

    public static void main(String[] args) {
        Z80InstructionSet disassembler = new Z80InstructionSet();

        disassembler.printInstructionSet();
    }
}
